<template>
	<el-dialog title="原料" :visible.sync="visibles" :close-on-click-modal="false" append-to-body center>
		<el-row :gutter="20">
			<el-col :span="6">
				<el-table highlight-current-row :data="dataList" border v-loading="dataListLoading" @row-click="clickRow" style="width: 100%;">
					<el-table-column prop="typeName" header-align="center" align="center" label="原料类型"></el-table-column>
				</el-table>
			</el-col>
			<el-col :span="18">
				<RawList @getRawList="getRaws" ref="RawListRef"></RawList>
			</el-col>
		</el-row>
		
	</el-dialog>
</template>

<script>
import RawList from './rawList.vue'	
export default {
	data() {
		return {
			dataForm: {
				key: ''
			},
			dataList: [],
			pageIndex: 1,
			pageSize: 10,
			totalPage: 0,
			dataListLoading: false,
			dataListSelections: [],
			visibles: false
		};
	},
	components: {
		RawList
	},
	

	methods: {
		getRaws(list){
			this.$emit("getRawList",list)
			this.visibles = false
		},
		
		clickRow(row, column, event){
			this.$refs.RawListRef.getDataList(row.id)
		},
		
		// 获取数据列表
		getDataList() {
			this.visibles = true;
			this.$http({
				url: this.$http.adornUrl('/factory/tfactoryrawmeterialtype/list'),
				method: 'get'
			}).then(({ data }) => {
				if (data && data.code === 0) {
					this.dataList = data.page.list;
					this.totalPage = data.page.totalCount;
				} else {
					this.dataList = [];
					this.totalPage = 0;
				}
			});
		},
	}
};
</script>
